export enum HttpMethod {
  GET = "GET",
  POST = "POST"
}

export interface JavaNetParams {
  url: string;
  method?: HttpMethod;
  headers?: {},
  params?: {};
}

export interface JavaNetModel<T> {
  code: number,
  message: string,
  askId: string,
  data: T,
  err: boolean
}


export interface TypeNetHeadModel {
  code: string,
  msg: string
}

export interface PhpNetModel<T> {
  head: TypeNetHeadModel,
  data: T
}

export function isPhpNetSuccess(phpNetModel: PhpNetModel<any>): boolean {
  const headOk = phpNetModel.head && phpNetModel.head.code == "200";
  let dataOk = false;
  if (phpNetModel.data) {
    if (phpNetModel.data.errcode == null || phpNetModel.data.errcode == "") {
      dataOk = true;
    } else if (phpNetModel.data.errcode == "ok") {
      dataOk = true;
    }
  }
  return headOk && dataOk;
}

export function isJavaNetSuccess(javaNetModel: JavaNetModel<any>): boolean {
  return javaNetModel.code == 0;
}
